package com.xyht.medicine_management_system.modules.medicineSource.controller;


import com.xyht.medicine_management_system.common.annotation.RequestPass;
import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.modules.medicineSource.entity.req.MmsMedicineSourceClassificationExchangeReq;
import com.xyht.medicine_management_system.modules.medicineSource.entity.req.MmsMedicineSourceClassificationReq;
import com.xyht.medicine_management_system.modules.medicineSource.entity.req.MmsMedicineSourceReq;
import com.xyht.medicine_management_system.modules.medicineSource.service.MmsMedicineSourceClassificationService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 药知源分类 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-01-04
 */
@RestController
@RequestMapping("/medicineSource/classification")
public class MmsMedicineSourceClassificationController {
    @Resource
    private MmsMedicineSourceClassificationService mmsMedicineSourceClassificationService;


    @PostMapping("/add")
    @ApiModelProperty(value = "添加药知源分类")
    public ResponseResult addClassification(@RequestBody MmsMedicineSourceClassificationReq sourceReq) {
        return mmsMedicineSourceClassificationService.addClassification(sourceReq);
    }

    @PostMapping("/delete")
    @ApiModelProperty(value = "删除药知源分类")
    public ResponseResult deleteClassification(@RequestBody MmsMedicineSourceClassificationReq sourceReq) {
        return mmsMedicineSourceClassificationService.deleteClassification(sourceReq);
    }

    @PostMapping("/update")
    @ApiModelProperty(value = "修改药知源分类")
    public ResponseResult updateClassification(@RequestBody MmsMedicineSourceClassificationReq sourceReq) {
        return mmsMedicineSourceClassificationService.updateClassification(sourceReq);
    }

    @GetMapping("/list")
    @ApiModelProperty(value = "药知源分类列表")
    public ResponseResult getMedicineSourceList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                @RequestParam("searchStr") String searchStr) {
        return mmsMedicineSourceClassificationService.getSourceClassificationList(pageNum, pageSize, searchStr);
    }

    @GetMapping("/detail")
    @ApiModelProperty(value = "药知源分类详情")
    public ResponseResult getMedicineSourceDetail(@RequestParam String id) {
        return mmsMedicineSourceClassificationService.getSourceClassificationDetail(id);
    }

    @PostMapping("/exchange")
    @ApiModelProperty(value = "排序药知源分类")
    public ResponseResult exchangeClassificationSort(@RequestBody MmsMedicineSourceClassificationExchangeReq sourceReq) {
        return mmsMedicineSourceClassificationService.exchangeClassificationSort(sourceReq);
    }

}

